package com.hzit.controller;

import com.hzit.config.HzitBeanConfig;
import com.hzit.config.JdbcBeanConfig;
import com.hzit.entity.R;
import jdk.nashorn.internal.objects.annotations.Getter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 类名：
 * 作者：WF
 * 功能：
 */
@RestController
public class HelloController {

	@Autowired
	private HzitBeanConfig config;
	@Autowired
	private JdbcBeanConfig jdbcBeanConfig;
	@GetMapping("/hello")
	public String hello(){
		return "hello,springboot!";
	}
	//1. 读取系统配置文件中的配置信息
	@GetMapping("/getConfig")
	public R getConfig(){
		return R.ok().put("stud",config.getStud()).put("books",config.getBooks()).put("map",config.getMap());
	}

	//2. 读取指定properties文件中的配置
	@GetMapping("getPropConfig")
	public R getPropConfig(){
		return R.ok().put("driver",jdbcBeanConfig.getDriver()).put("url",jdbcBeanConfig.getUrl());
	}
}
